package com.sxdz.controller.service.order

import com.sxdz.controller.mapper.TOrderMapper
import com.sxdz.controller.service.BaseService
import groovy.transform.CompileStatic
import groovy.transform.TypeChecked
import com.sxdz.models.TOrder
import com.toolbox.utils.ClearNullUtil
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Service

/**
 * Created by LiYan on 2016/8/2.
 */
@Service
@CompileStatic
@TypeChecked
class OrderService extends BaseService implements IOrderService{
@Autowired
    private TOrderMapper tOrderMapper;

    @Autowired
    void setTOrderMapper(TOrderMapper orderMapper) {
        this.tOrderMapper = orderMapper
        super.baseMapper=orderMapper
    }

    @Override
    Long addBasic(def obj) throws Exception {
        tOrderMapper.insertSelective((TOrder)obj);
    }

    @Override
    void modifyBasic(def obj) throws Exception {
        tOrderMapper.updateByPrimaryKeySelective(obj as TOrder)
    }

    @Override
    void delBasic(def obj) throws Exception {}

    List<TOrder> findListByDate(Map<String, Object> params) throws Exception {
        ClearNullUtil.mapClear(params)
        return tOrderMapper.selectByDate(params)
    }

    @Override
    List<TOrder> findListByStatus(String status) {
        return tOrderMapper.selectByStatus(status);
    }

    TOrder findObj(Map<String, Object> params){
        ClearNullUtil.mapClear(params)
        return tOrderMapper.selectByParams(params)
    }

    @Override
    int deleteOrder(Long id) {
        return tOrderMapper.deleteByPrimaryKey(id);
    }
}
